package com.itheima.mapper;

import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 部门管理
 */
@Mapper
public interface DeptMapper {

    /**
     * 查询所有部门信息
     * @return
     */
    @Select("select * from dept")
    public List<Dept> getDepts();


    /**
     * 根据部门id删除部门信息
     * @param id
     */
    @Delete("delete from dept where id = #{id}")
    public void deleteDeptById(Integer id);

    /**
     * 添加部门信息
     * @param dept(name, createTime, updateTime)
     */
    @Insert("insert into dept (name, create_time, update_time) values (#{name}, #{createTime}, #{updateTime})")
    public void addDept(Dept dept);

    /**
     * 根据部门id查询部门信息
     * @param id
     * @return
     */
    @Select("select * from dept where id = #{id}")
    public Dept getDeptById(Integer id);

    @Update("update dept set name = #{name}, update_time = #{updateTime} where id = #{id}")
    void updateDept(Dept dept);
}
